<!--{template lyear:header_simple_start}-->
<style>
.thumbnails li {
	float: left;
}
.thumbnail {
	border: none;
	box-shadow: none;
}
#upload_progress .back {
	position: absolute;
	width: 200px;
	text-align: center;
	color: #900;
	font-weight: bold;
}
#upload_progress .back span {
	padding: 0 5px;
}
</style>
<!--{template lyear:header_simple_end}-->
<main class="bs-main-container">
	<div class="container-fluid">
		<!--{template right_header}-->
		<div class="card">
			<div class="card-body">
				<div class="text-center">
					<p id="operation" class="text-center">
					<button class="btn btn-outline-primary start" onclick="moveing_start('start')">{lang starting_migration}</button>
					&nbsp; &nbsp;
					<button class="btn btn-danger stop" onclick="moveing_start('stop')" disabled="disabled">{lang stop}</button>
					&nbsp; &nbsp; </p>
					<ul class="thumbnails list-unstyled clearfix d-flex justify-content-center">
					<li id="source_space" style="width:150px;">
						<div class="thumbnail"> 
						<!--{if $sourcedata[bz]=='dzz'}--> 
						<img src="dzz/images/default/system/home.png" width="100"> 
						<!--{else}--> 
						<img src="dzz/images/default/system/$sourcedata[bz].png" width="100"> 
						<!--{/if}-->
						<h5 class="text-center" style="line-height:20px;margin-bottom:5px"><a href="javascript:;" title="$sourcedata[name]">$sourcedata[name] </a></h5>
						</div>
					</li>
					<li id="moveinfo">
						<div id="upload_progress" style="width:200px;overflow:hidden">
						<h5 class="progress-subject" style="margin-top:5px"></h5>
						<h5 class="progress-title">$first[attachment]</h5>
						<div class="progress">
							<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 1%;" aria-valuenow="25" aria-valuemin="0" aria-valuemax="100"><div style="display: inline-block;"><span id="moved">$first[fsize]</span>/<span>$fmovesize</span></div></div>
						  </div>
						</div>
					</li>
					<li id="target_space" style="width:150px;">
						<div class="thumbnail"> 
						<!--{if $targetdata[bz]=='dzz'}--> 
						<img src="dzz/images/default/system/home.png" width="100"> 
						<!--{else}--> 
						<img src="dzz/images/default/system/$targetdata[bz].png" width="100"> 
						<!--{/if}-->
						<h5 class="text-center" style="line-height:20px;margin-bottom:5px"><a href="javascript:;" title="$targetdata[name]">$targetdata[name]</a></h5>
						</div>
					</li>
					</ul>
				</div>
				<div class="alert alert-warning alert-dismissible fade show" role="alert">
					<h2>{lang board_message}</h5><ul class="mb-0">{lang cloud_movetool_board_message_text1}</ul>
					<button type="button" class="btn-close" data-dismiss="alert" aria-label="Close"></button>
				</div>
			</div>
		</div>
	</div>
</main>
<iframe id="hideframe" name="hideframe" src="about:blank" frameborder="0" marginheight="0" marginwidth="0" width="0" height="0" allowtransparency="true" style="display:none;z-index:-99999"></iframe>
<script type="text/javascript">
	var runurl = '$runurl';
	var sizemoved = 0;
	var totalsize = parseInt('$movesize');
	var ignore = [];
	var ignore_attach = {};
	var attach = {};
	var ignoreTimer = null;

	function setProgress(data) {
		attach = data;
		var el = jQuery('#upload_progress');
		if(data.error) {
			el.find('.progress-title').html(data.attachment);
			var html = '';
			html += '<p><span class="text-danger">' + data.error + '</span></p>';
			html += '<p><span class="text-info">{lang filename}：' + data.attachment + '</span>';
			html += '<p><span class="text-info">{lang big_small}：' + formatSize(data.filesize) + '</span></p>';
			html += '<p><a href="javascript:;" onclick="moveing_start(\'retry\')">{lang founder_upgrade_reset}</a>&nbsp;&nbsp;<a href="javascript:;" onclick="moveing_start(\'ignore\');">{lang ignore_continue}</a></p>';
			ignoreTimer = window.setTimeout(function() { moveing_start('ignore'); }, 1000);
			el.find('.progress-subject').html(html);
		} else {
			el.find('.progress-subject').html('{lang moving}');
			sizemoved += parseInt(data.filesize);
			el.find('.progress-title').html(data.attachment);
			el.find('#moved').html(formatSize(sizemoved));
			jQuery('#upload_progress .progress-bar').css('width', Math.floor((sizemoved / totalsize) * 100));
		}

	}

	function setComplete() {
		var html = '';
		html += '<p><span class="text-success">{lang migration_completed}</span></p>';
		if(ignore.length > 0) {
			html += '<p class="text-warning">' + ignore.length + '{lang cloud_movetool_file_neglect}</p>';
		}
		jQuery('#upload_progress .progress-bar').css('width', '100%');
		jQuery('#upload_progress .progress-subject').html(html);
		jQuery('#operation .stop').attr('disabled', true);
		jQuery('#operation .start').attr('disabled', true);
	}

	function moveing_start(op) {
		if(ignoreTimer) window.clearTimeout(ignoreTimer);
		if(op == 'start') {
			jQuery('#operation .stop').removeAttr('disabled');
			jQuery('#operation .start').attr('disabled', true);
			jQuery('#upload_progress .progress-subject').html('{lang moving}');
			jQuery('#upload_progress .progress-bar').css('width', Math.floor((sizemoved / totalsize) * 100));
			window.frames['hideframe'].location = runurl ;
		} else if(op == 'stop') {
			jQuery('#operation .start').removeAttr('disabled');
			jQuery('#operation .stop').attr('disabled', true);
			window.frames['hideframe'].location = 'about:blank';
			jQuery('#upload_progress .progress-subject').html('{lang stopped}');
		} else if(op == 'ignore') {
			ignore.push(attach.aid);
			ignore_attach[attach.aid] = attach;
			jQuery('#upload_progress .progress-subject').html('{lang ignored}');
			sizemoved += parseInt(attach.filesize);
			jQuery('#upload_progress .progress-bar').css('width', Math.floor((sizemoved / totalsize) * 100));
			window.frames['hideframe'].location = runurl+'&dateline='+attach.dateline+'&aid1='+attach.aid ;
		} else if(op == 'retry') {
			jQuery('#upload_progress .progress-subject').html('{lang are_retry}');
			jQuery('#upload_progress .progress-bar').css('width', Math.floor((sizemoved / totalsize) * 100));
			window.frames['hideframe'].location = runurl ;
		} else if(op == 'refresh') {
			window.location.reload();
		}
	}

	function formatSize(bytes) {
		var i = -1;
		do {
			bytes = bytes / 1024;
			i++;
		} while (bytes > 99);

		return Math.max(bytes, 0).toFixed(1) + ['kB', 'MB', 'GB', 'TB', 'PB', 'EB'][i];
	};
</script> 
<!--{template lyear:footer_simple}-->